<?php
/**
 * cron获取更新状态
 * @code-encode utf-8
 * @data-encode utf-8
 */


class db_cron_get_manage extends db_base
{
	var $tbl_name = "cron_get_manage";

	/**
	 * 构造函数
	 */
	function __construct()
	{
		parent::db_base();
	}
	
	
	/*
	* 根据类型取数据
	*/
	function cron_get_item_by_key($get_key)
	{
	
		$where = "get_key = '{$get_key}'";
	
		$res = $this->get_alllist($this->tbl_name,1,1,"",$where);
		
		return $res[0];
	}

	/*
	 * 插入cron数据 
	 */
	function cron_replace_into_data($get_key,$get_num,$get_num_end)
	{
		$data = $this->cron_get_by_key($get_key);
		if($data)
		{
			$where ="get_key = '{$get_key}'";
			if($get_num)$arr_insert_data["get_num"] = $get_num;
			if($get_num_end)$arr_insert_data["get_num_end"] = $get_num_end;
			
			$res = $this->update($this->tbl_name, $arr_insert_data,$where);
		}
		else
		{
			$arr_insert_data["get_key"] = $get_key;
			if($get_num || $get_num_end)
			{
				$arr_insert_data["get_num"] = $get_num;
				$arr_insert_data["get_num_end"] = $get_num_end;
				$res = $this->insert($this->tbl_name, $arr_insert_data);
			}
			
		}
		
		return $res;
	}

	
	function cron_get_by_key($get_key)
	{
		$where ="get_key = '{$get_key}'";
		$res = $this->get_alllist($this->tbl_name,1,1,"",$where);
		return $res;
	}

}